<?php

namespace Home\Controller;

use Faker\Factory;
use Think\Controller;

class PagesController extends Controller
{

    /*public function generate()
    {
        $faker = Factory::create();
        $this->faker([
            'id' => $faker->numberBetween(1,10),
            'name' => $faker->name,
            'location' => $faker->address ,
            'time' => $faker->dayOfWeek ,
            'description' => $faker->text ,
            'seats' => $faker->numberBetween(5,30) ,
            'type' => $faker->title,
            'manager' => $faker->lastName ,
            'pic' => $faker->imageUrl($width = 250, $height = 200)
        ], 20);
    }*/

    /*protected function faker($rule, $times = 10)
    {
        $faker = Factory::create();
        $arr = [];

        for ($i = 0; $i < $times; $i++) {
            array_push($arr, $rule);
        }

        return $arr;
    }*/

    public function test()
    {
        $faker = Factory::create();  //引入测试数据

        $levels=[];
        for ($i = 0; $i < $faker->numberBetween(1,3); $i++) {
            //循环依次给该数组赋值一套数据
            $levels[] = [
                'level_name' => $faker->bothify('#级评审'),
                'mode' => $faker->numberBetween(1,2)
            ];
        }

        //foreach 循环为数组赋值，&符号表示引用，为该变量本身赋值，若不使用则只是copy了一份数据到副本里，并没有赋值成功
        foreach ($levels as $key => &$level) {
            //给levels数组中每一个子数据新添一个属性reviewers
            for ($i = 0; $i < $faker->numberBetween(1,5); $i++) {
                $level['reviewers'][] = [
                    'name' => $faker->firstName,
                    'age' => $faker->numberBetween(20, 40),
                    'created_at' => $faker->unixTime,
                    'amount' => $faker->numberBetween(100000, 99999999),
                    'description' => $faker->sentence(100),
                ];
            }
        }

        $test = [
            'no' => $faker->swiftBicNumber,
            'author' => $faker->firstName,
            'levels' => $levels
        ];

        $this->assign('test', $test);  //赋值变量
        $this->display();
    }
    /**
     * *BBS
     */
    //设置签名档
    public function bbsSignCreate()
    {
        $this->display('Pages/bbs/signCreate');
    }

    //投票模块的详情页
    public function bbsVoteShow()
    {
        $this->display('Pages/bbs/voteShow');
    }

    //投票模块的创建页
    public function bbsVoteCreate()
    {
        $this->display('Pages/bbs/voteCreate');
    }


    /**
     * *工作指示
     */
    //工作指示-首页
    public function workInstructionIndex()
    {
        $this->display();
    }

    //工作指示-我发起的
    public function workInstructionMy()
    {
        $this->display();
    }

    //工作指示-待我完成的
    public function workInstructionTodo()
    {
        $this->display();
    }

    //工作指示-我已完成的
    public function workInstructionDone()
    {
        $this->display();
    }

    //工作指示-发布任务
    public function workInstructionAdd()
    {
        $this->display();
    }

    //工作指示-任务详情
    public function workInstructionDetail()
    {
        $this->display();
    }


    /**
     * *会议管理
     */
    //会议管理-会议室管理
    public function meetingRoomIndex()
    {
        $faker = Factory::create();  //引入测试数据
        $room = [];
        for ($i = 0; $i < 4; $i++) {
            array_push($room, [
                'id' => $faker->numberBetween(1,10),
                'name' => $faker->name,
                'location' => $faker->address ,
                'time' => $faker->dayOfWeek ,
                'description' => $faker->text ,
                'seats' => $faker->numberBetween(5,30) ,
                'type' => $faker->title,
                'manager' => $faker->lastName ,
                'pic' => $faker->imageUrl($width = 250, $height = 200)
            ]);
        }
        $this->assign('room',$room);
        $this->display('Pages/meeting/room');
    }

    //会议管理-创建会议室
    public function meetingRoomCreate()
    {
        $faker = Factory::create();  //引入测试数据
        $user = [];
        for ($i = 0; $i < 10; $i++) {
            array_push($user, [
                'name' => $faker->name,
                'value' => $faker->numberBetween(1, 300)
            ]);
        }

        $this->assign('user', $user);  //赋值变量
        $this->display('Pages/meeting/roomCreate');
    }

    //会议管理-编辑会议室
    public function meetingRoomEdit()
    {
        $faker = Factory::create();  //引入测试数据
        $user = [];
        for ($i = 0; $i < 10; $i++) {
            array_push($user, [
                'name' => $faker->lastName,
                'value' => $faker->numberBetween(1, 300)
            ]);
        }
        $edit=[
            'name' => $faker->name,
            'location' => $faker->address ,
            'time' => ['周一','周三'] ,
            'description' => $faker->text ,
            'seats' => $faker->numberBetween(5,30) ,
            'type' => '类型2',
            'manager' => $faker->lastName
        ];
        $this->assign('edit',$edit); //获取到数据库中的数据
        $this->assign('user', $user);  //赋值选择框变量
        $this->display('Pages/meeting/roomEdit');
    }

    //会议管理-申请会议
    public function meetingCreate()
    {
        $faker = Factory::create();
        $user = [];
        for ($i = 0; $i < 10; $i++) {
            array_push($user, [
                'name' => $faker->lastName,
                'value' => $faker->numberBetween(1, 300)
            ]);
        }
        $room = [];
        for ($i = 0; $i < 4; $i++) {
            array_push($room, [
                'img' => $faker->imageUrl($width = 230, $height = 200),
                'name' => $faker->word,
                'value' => $faker->randomDigitNotNull,
                'seats' => $faker->numberBetween(5,30),
                'type' => $faker->bothify('类型#'),
                'manger' => $faker->lastName,
                'location' => $faker->streetAddress,
                'num' => $faker->randomDigitNotNull
            ]);
        }
        $table = [];
        for ($i = 0; $i < 4; $i++) {
            array_push($table, [
                'meetingName' => $faker->word,
                'create' => $faker->lastName,
                'start_time' => $faker->unixTime,
                'end_time' => $faker->unixTime
            ]);
        }
        $this->assign('user',$user);
        $this->assign('room',$room);
        $this->assign('table',$table);
        $this->display('Pages/meeting/create');
    }

    //会议管理-我的会议
    public function meetingIndex()
    {
        $faker = Factory::create();

        $this->display('Pages/meeting/index');
    }

    //会议管理-会议详情
    public function meetingShow()
    {
        $faker = Factory::create();
        $users = [];
        for ($i = 0; $i< $faker->numberBetween(1,10); $i++) {
            array_push($users, [
                'name' => $faker->lastName,
                'face' => $faker->imageUrl($width = 60, $height = 60)
            ]);
        }
        $data = [
            'host' => [
                'name' => $faker->lastName,
                'face' => $faker->imageUrl($width = 40, $height = 40)
            ],
            'recorder' => [
                'name' => $faker->lastName,
                'face' => $faker->imageUrl($width = 40, $height = 40)
            ],
            'start_time' => $faker->unixTime,
            'end_time' => $faker->unixTime,
            'meeting_name' => $faker->words(3,true),
            'room_name' => '绵阳三楼会议室、成都会议室',
            'meeting_content' => $faker->sentence,
            'users' => $users,
            'remark' => $faker->text(200),
            'meeting_summary' => $faker->text(500),
            'meeting_status' => $faker->numberBetween(0,2)
        ];

        $this->assign('data',$data);
        $this->display('Pages/meeting/show');
    }

    //会议管理-编辑会议
    public function meetingEdit()
    {
        $faker = Factory::create();
        $user = [];
        for ($i = 0; $i < 10; $i++) {
            array_push($user, [
                'name' => $faker->lastName,
                'value' => $faker->numberBetween(1, 10)
            ]);
        }
        $room = [];
        for ($i = 0; $i < 4; $i++) {
            array_push($room, [
                'img' => $faker->imageUrl($width = 230, $height = 200),
                'name' => $faker->word,
                'value' => $faker->randomDigitNotNull,
                'seats' => $faker->numberBetween(5,30),
                'type' => $faker->bothify('类型#'),
                'manger' => $faker->lastName,
                'location' => $faker->streetAddress,
                'num' => $faker->randomDigitNotNull
            ]);
        }
        $table = [];
        for ($i = 0; $i < 4; $i++) {
            array_push($table, [
                'meetingName' => $faker->word,
                'create' => $faker->lastName,
                'start_time' => $faker->unixTime,
                'end_time' => $faker->unixTime
            ]);
        }
        //赋值数据
        $data=[
            'title' => $faker->sentence(3, true),
            'content' => $faker->sentences(3, true),
            'start_time' => $faker->unixTime, //返回随机时间戳
            'end_time' => $faker->unixTime,
            'host' => $faker->numberBetween(1, 10),
            'recorder' => $faker->numberBetween(1, 10),
            'users' => $faker->numberBetween(1, 10),
            'location' => ['绵阳三楼会议室','成都会议室'],
            'meeting_room' => $faker->randomDigitNotNull,
            'seats' => $faker->numberBetween(5,30),
            'type' => $faker->bothify('类型#'),
            'manger' => $faker->lastName,
            'room_location' => $faker->streetAddress,
            'num' => $faker->randomDigitNotNull,
            'remark' => $faker->text(300),
        ];

        $this->assign('user',$user);
        $this->assign('room',$room);
        $this->assign('table',$table);
        $this->assign('data',$data);
        $this->display('Pages/meeting/edit');
    }

    //会议管理-会议纪要
    public function meetingContentIndex()
    {
        $data=[];

        $this->assign('data',$data);
        $this->display('Pages/meeting/content');
    }

    //会议管理-会议纪要详情
    public function meetingContentShow()
    {
        $this->display('Pages/meeting/contentShow');
    }


    /**
     * *hr
     */
    //员工定期谈话记录-首页
    public function staffInterviewIndex()
    {
        $this->display();
    }

    //员工定期谈话记录-创建记录
    public function staffInterviewCreate()
    {
        $this->display();
    }

    //员工定期谈话记录-记录详情
    public function staffInterviewDetail()
    {
        $this->display();
    }


    /**
     * *供应商
     */
    //创建赔偿处罚单
    public function supplierCompensationCreate()
    {
        $this->display();
    }

    //赔偿处罚单详情
    public function supplierCompensationDetail()
    {
        $this->display();
    }

    /**
     * *评审
     */
    //创建评审规则
    public function reviewRuleCreate()
    {
        $this->display();
    }

    //评审工作流程创建页
    public function reviewCreate()
    {
        $this->display();
    }
}